-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Call selectedUnitsHandler.RemoveUnit when a unit is killed. #1824
base: master
Are you sure you want to change the base?
Call selectedUnitsHandler.RemoveUnit when a unit is killed. #1824
Conversation
Engine should leave decisions to Lua, especially when it's trivial to do so there. What if I want to keep a unit with long death animation selected? Just deselect the unit in Lua UnitDestroyed. |
This is causing real problems and very difficult to debug too. |
For your use case they can reselect in SelectionChanged. Imo it's much more niche and who knows how many widgets or gadgets have the issue this fixes. |
@sprung see the above issue from bar to see how easy it can be to fix bugs caused by this behaviour. |
|
Man, when a unit is killed and UnitDestroyed is called it should be removed automatically from selection, that's the most reasonable behaviour. Why would you reselect it? If you do of course you're on your own with all the problems you would cause in other places. I think that's totally reasonable. Also I already noted this can result in difficult to track bugs it already cost me hours just to find what was going on, and also possibly other devs as well. Totally the last thing I expected was for the unit to still be there at the selection after I got it removed from visibleUnits and got UnitDestroyed too. It's removed from basically everywhere. |
Having a destroyed unit selected does not make semantic sense. |
It does at an engine level. But a game could disagree and it could make no sense within its design, in which case it is free to make such units unselectable via 1 line of Lua.
The most reasonable behaviour is for the engine to let games decide on their own UI design via Lua, and facilitating that design's implementation in the form of "do X" rather than "work around the engine implementing some specific behaviour X".
There aren't actually any problems inherent to selecting dead units. BAR just has some broken wupget that handles it incorrectly, fix it (or use the 1-liner to work around it).
Not from the places relevant here. Check |
In the spirit of the "reasonable defaults" I think we should be able to agree the reasonable behaviour is to have them unselected, and then having games wanting otherwise to override that in some way. Otherwise we're just forcing games to workaround broken behaviour. Actually I'm pretty sure the games must already be working around that since otherwise there would be more problems with all those selected but dead units.
Could be to workaround some other broken behaviour, but can't be sure tbh. |
A good topic for you to investigate.
Another good topic to investigate. |
if (isSelected) | ||
selectedUnitsHandler.RemoveUnit(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (isSelected) | |
selectedUnitsHandler.RemoveUnit(this); | |
/* This is a hack and should be done gadget-side, | |
* because else it's a hassle to keep the unit selected | |
* if you'd rather that was the behaviour. */ | |
if (isSelected) | |
selectedUnitsHandler.RemoveUnit(this); |
Work Done
Remarks
How to test